from qcloudsms_py import SmsSingleSender
from qcloudsms_py.httpclient import HTTPError

class TXYSend():
    def __init__(self):
        self.appid = 1400601721  # SDK AppID 以1400开头
        # 短信应用 SDK AppKey
        self.appkey = "a078dab8abb29c41e7af8ee08002c533"

        # 短信模板ID，需要在短信控制台中申请
        self.template_id = 1212660  # NOTE: 这里的模板 ID`7839` 只是示例，真实的模板 ID 需要在短信控制台中申请
        # 签名
        self.sms_sign = "python面试总结"  # NOTE: 签名参数使用的是`签名内容`，而不是`签名ID`。这里的签名"腾讯云"只是示例，真实的签名需要在短信控制台中申请

    def send_sms(self,phone,code):
        ssender = SmsSingleSender(self.appid,self.appkey)
        try:
            result = ssender.send_with_param(86,phone,self.template_id,code,sign=self.sms_sign,extend="",ext="")
            return result
        except HTTPError as e:
            print(e)
        except Exception as e:
            print(e)



txysend = TXYSend()


